{extend name="common/main"}

{block name="css"}
<style>
    #dd{
        float: right;
        margin-top:30px;
    }
</style>
<!-- 本页面需要额外添加的css请在此处添加 -->
{/block}
{block name="body"}
<body>
<header>
    <div class="tab_nav">
        <div class="header">
            <div class="h-left"><a class="sb-back" href="{:url('User/index')}" title="返回"></a></div>
            <div class="h-mid">我的订单</div>
            <div class="h-right">
                <aside class="top_bar">
                    <div onClick="show_menu();$('#close_btn').addClass('hid');" id="show_more"><a href="javascript:;"></a> </div>
                </aside>
            </div>
        </div>
    </div>
</header>
{include file="common/goods_nav"}
<div id="tbh5v0">
    <!--------筛选 form 表单 开始-------------->
    <form action="{:url('Mobile/order_list/ajax_order_list')}" name="filter_form" id="filter_form">
        <div class="Evaluation2">
            <ul>
                <li><a href="{:url('User/order_list')}" class="tab_head {if $type eq ''}on{/if}"  >全部</a></li>
                <!--<li><a href="{:url('/mobile/User/order_list',array('type'=>'WAITPAY'))}"      class="tab_head {if $type eq 'WAITPAY'}on{/if}">待付款</a></li>-->
                <li><a href="{:url('User/order_list',array('type'=>'WAITSEND'))}"     class="tab_head {if $type eq 'WAITSEND'}on{/if}">待发货</a></li>
                <li><a href="{:url('User/order_list',array('type'=>'WAITRECEIVE'))}"  class="tab_head {if $type eq 'WAITRECEIVE'}on{/if}">待收货</a></li>
                <li><a href="{:url('User/order_list',array('type'=>'WAITCCOMMENT'))}" class="tab_head {if $type eq 'WAITCCOMMENT'}on{/if}">已完成</a></li>
                <li><a href="{:url('User/return_goods_list')}"      class="tab_head {if $type eq 'WAITPAY'}on{/if}">退/换</a></li>

            </ul>
        </div>

        <div class="order ajax_return">
            {volist name="lists" id="list"}
                <div class="order_list">
                    <h2>
                        <a href="{:url('User/order_detail',array('id'=>$list['order_id']))}">
                            <img src="/mobiled/images/dianpu.png"><span>订单号:{$list.order_sn}</span>
                            <strong>{if condition="$list['order_status'] eq 5"}<b>已作废</b>{/if}
                                <img src="/mobiled/images/icojiantou1.png"></strong>
                        </a>
                    </h2>
                    <a href="{:url('User/order_detail',array('id'=>$list['order_id']))}">
                        {volist name="list.goods_list" id="good"}
                            <dl style="position: relative">
                                <dt><img src="{$good.goods_id|goods_thum_images=200,200}"></dt>
                                <dd class="name"><strong>{$good.goods_name}</strong>
                                    <span style="position: absolute;">{$good.spec_key_name} </span></dd>
                                <dd class="pice">￥{$good['member_goods_price']}元<em>x{$good['goods_num']}</em></dd>
                                <dd class="pice" id="dd">
                                    <em>
                                        {if condition="($list['return_btn'] eq 1) and ($good['is_send'] eq 1) and ($list['order_status'] !=2)  "}

                                            <a href="{:url('User/return_goods',array('order_id'=>$list['order_id'],'order_sn'=>$list['order_sn'],'order_goods_id'=>$good['rec_id'],'goods_id'=>$good['goods_id'],'spec_key'=>$good['spec_key'],'rec_id'=> $good['rec_id']))}" style="color:#FF3300;">退/换</a>

                                        {/if}
                                    </em>
                                </dd>
                            </dl>
                        {/volist}
                    </a>
                    <div class="pic">共{$list.goods_list|count}件商品<span>实付：</span><strong>￥{$list['order_amount']}元</strong></div>
                    <div class="anniu" style="width:95%">
                        {if condition="$list.cancel_btn eq 1"}<span onClick="cancel_order({$list.order_id})">取消订单</span>{/if}
                        {if condition="$list.pay_btn eq 1"}<a href="{:url('classify/pay')}?order_id={$list['order_id']}">立即付款</a>{/if}
                        {if condition="$list.receive_btn eq 1"}<a onclick="order_confirm({$list['order_id']})">收货确认</a>{/if}
                        {if condition="$list.comment_btn eq 1"}<a href="{:url('User/comment')}">评价</a>{/if}
                        {if condition="$list.shipping_btn eq 1"}<a href="http://www.kuaidi100.com/?nu={$list['invoice_no']}">查看物流</a>{/if}
                    </div>
                </div>
            {/volist}
        </div>
        <!--查询条件-->
        <input type="hidden" name="type" value="{$type}" />
    </form>
    {notempty name="lists"}
        <div id="getmore" style="font-size:.24rem;text-align: center;color:#888;padding:.25rem .24rem .4rem; clear:both">
            <a href="javascript:void(0)" onClick="ajax_sourch_submit()">点击加载更多</a>
        </div>
    {/notempty}
</div>
{include file="common/bar"}
</body>
{/block}

{block name="js"}
<script src="/layer/layer.js"></script>
<script language="javascript">
    var  page = 1;

    /*** ajax 提交表单 查询订单列表结果*/
    function ajax_sourch_submit()
    {
        page += 1;
        $.ajax({
            type : "POST",
            url:"{:url('User/order_list')}",
            data : {
                page:page,
                type:'{$type}'
            },
            success: function(data)
            {
                if(data == '')
                    $('#getmore').hide();
                else
                {
                    $(".ajax_return").append(data);
                    $(".m_loading").hide();
                }
            }
        });
    }
    function order_confirm(id) {
        $.post("{:url('order_confirm')}", {id: id}, function (res) {
            if (res.code == 201) {
                layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                return false;
            }
            location.href = "{:url('User/order_list')}";
        });
    }
    //取消订单
    function cancel_order(id){
        layer.confirm("确定删除？", {btn: ["确定","取消"], shade: 0.5}, function(){
            // 删除权限组
            $.post("{:url('User/cancel_order')}", {id: id}, function(res) {
                if (res.code == 201) {
                    layer.msg(res.msg, {shade: 0.5, time: 1000, icon: 2});
                    return false;
                }
                    location.href = "{:url('User/order_list')}";

            });
        }, function () {});
    }

</script>
{/block}